Using Drag & Drop and Programmatically Together

All server controls can be further manipulated after dragging and dropping them on a web form by using the code behind. Here is an example of using a drag and drop ListSummary Server Control then modifying it programmatically.

First, drag and drop a List Summary on your Web form and set your properties.

Then add the following code to the code behind.

Dim myString As String

Dim i

For i = LBound(ListSummary1.EkItems) To UBound(ListSummary1.EkItems)

myString &= "<a href=""" & ListSummary1.EkItems(i).QuickLink & """>" & ListSummary1.EkItems(i).DateCreated & "</a><br>"

ListSummary1.Text = myString

Next

An Explanation of the code:

ListSummary1 is the ID of the object. It is used to get access to its properties.

Create a string that contains the output (myString).

Dim myString As String

Set the object’s Text property to that string.

myString &= "<a href=""" & ListSummary1.EkItems(i).QuickLink & """>" & ListSummary1.EkItems(i).DateCreated & "</a><br>"

Wrap in a loop so it loops through each of the items.

Dim i

For i = LBound(ListSummary1.EkItems) To UBound(ListSummary1.EkItems)

Next

This example outputs the date created for each content block in a List Summary.

(continued in Data Binding with Server Controls)

Previous TopicNext Topic|